package exdate;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author: knowno
 * @create: 2025-09-15 09:39
 * @Version 1.0
 **/
public class TestDateTimeFormatter {
    public static void main(String[] args) {
        //1 创建本地日期对象 LocalDateTime.now()
        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime);

        //2 转换为字符串
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");

        String format = dateTime.format(dateTimeFormatter);
        System.out.println(format);

        //3 把字符串转化为时间日期格式
        //public static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter) {
        LocalDateTime parse = LocalDateTime.parse(format, dateTimeFormatter);
        System.out.println(parse);

    }
}
